<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@ include file="/WEB-INF/views/shared/taglib.jsp"%>

<%@ include file="/WEB-INF/views/shared/master/contentHeader.jsp"%>
<%@ include file="/WEB-INF/views/shared/master/index.jsp"%>
<style type="text/css">

</style>

<t:form commandName="proposalSearch" action="/admin/proposal/index" ajaxPost="true" onSuccess="onSuccess">
	<t:panel cssClass="panel-flat border-top-xlg border-top-primary" customBody="true" customHead="true">
		<t:panelHead title="开题报告"></t:panelHead>
		<div class="panel-body">
			<div class="row">
				<c:import url="input.jsp" />
			</div>
			<div id="view" class="row">
				<c:import url="output.jsp" />
			</div>
			<div id="tableContent" class="row">
				<c:import url="outputSon.jsp" />
			</div>
		</div>
	</t:panel>
</t:form>

<script type="text/javascript">

	var selectedProposalName;

	$(function(){
		bindProposalClick();
	});

	function onSuccess(res){
		c.log(res);
		$("#view").html(res);
		
		bindProposalClick();

		var proposalName = selectedProposalName;
		$.ajax({
			type:"post",
			url:'${t_virtualpath}/admin/proposal/loadProposal',
			data:{"proposalName":proposalName},
			dataType:"html",
			success:function(html){
				c.log(html);
				$("#tableContent").html(html);
			}			
		})
		
		redrawTable();
	}
	function searchCallback(){
		formSubmit();
	}
	function pagerChangeCallback(){
		formSubmit();
	}
	function sortingCallback(){
		formSubmit();
	}
	function formSubmit(){
		$("form:first").submit();	
	}
	function bindProposalClick(){
		$(".panel-proposal").on("click",function(){
			if($(this).hasClass("bg-proposal")){
				$(this).removeClass("bg-proposal");
			}else{
				$(".panel-proposal.bg-proposal").removeClass("bg-proposal");
				$(this).addClass("bg-proposal");
			}
			var proposalName = $(".bg-proposal").attr("data-name");
			selectedProposalName = proposalName;
			$.ajax({
				type:"post",
				url:'${t_virtualpath}/admin/proposal/loadProposal',
				data:{"proposalName":proposalName},
				dataType:"html",
				success:function(html){
					c.log(html);
					$("#tableContent").html(html);
				}			
			})
		});
	}
</script>

<%@ include file="/WEB-INF/views/shared/master/cntable.jsp"%>

<%@ include file="/WEB-INF/views/shared/base/scripts/jqueryui.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formbuttons.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formstyling.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formselects.jsp"%>

<%@ include file="/WEB-INF/views/shared//master/contentFooter.jsp"%>